<template>
  <div class="hot">
    <h5>热点新闻</h5>
    <ul>
      <li v-for="item in newsList" :key="item.id"><nuxt-link :to="`/news/${item.id}`">{{ item.title }}</nuxt-link></li>
    </ul>
  </div>
</template>

<script>
export default {
  async asyncData({ $api }) {
    const { code, data } = await $api.getNewsList({ type: 1 })

    let newsList = []

    if(code === 200) {
      newsList = data
    }
    return {
      newsList
    }
  },
  mounted() {
    console.log(this.newsList)
  }
}
</script>

<style lang="scss" scoped>
.hot {
  padding: 0 40px;
}
</style>
